package com.item.controller;

import com.item.domain.VideoOrderPay;
import com.item.service.VideoOrderPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class VideoOrderPayController {

    @Autowired
    VideoOrderPayService videoOrderPayService;

    @PostMapping(value = "/video/order/{limit}/{page}")
    public List<VideoOrderPay> videoOrderPay(
            @PathVariable(value = "limit", required = false) int limit,
            @PathVariable(value = "page", required = false) int page,
            @RequestBody(required = false) VideoOrderPay videoOrderPay) {

        List<VideoOrderPay> videoOrderPays = videoOrderPayService.findAll(limit, page, videoOrderPay);
        return videoOrderPays;
    }

    @PostMapping(value = "/video/order/add")
    public Integer videoOrderPayAdd(@RequestBody VideoOrderPay videoOrderPay) {

        int i = videoOrderPayService.add(videoOrderPay);
        return i;
    }

    @PutMapping(value = "/video/order/update")
    public Integer videoOrderPayUpdate(@RequestBody VideoOrderPay videoOrderPay) {

        int i = videoOrderPayService.update(videoOrderPay);
        return i;
    }

    @DeleteMapping(value = "/video/order/{id}")
    public Integer videoOrderPayDelete(@PathVariable(value = "id") int id) {

        int i = videoOrderPayService.delete(id);
        return i;
    }

    @PutMapping(value = "/video/order/del/{id}/{del}")
    public Integer VideoOrderPayDeleteDel(@PathVariable(value = "id") int id, @PathVariable(value = "del") int del) {

        int i = videoOrderPayService.videoOrderDeleteDel(id, del);
        return i;
    }

}
